<template>
  <div class="app-container">

    <el-row :gutter="24">

      <el-col :span="24" style="margin-bottom: 20px">

        <el-alert
          title="点击`练习`后将自动进入练习页面！"
          type="error"
          style="margin-bottom: 10px"
        />

        <el-card class="pre-exam">

          <div><strong>题库名称：</strong>{{ detailData.title }}</div>
          <div><strong>单选题数量：</strong>{{ detailData.radioCount }}个</div>
          <div><strong>多选题数量：</strong>{{ detailData.multiCount }}个</div>
          <div><strong>判断题数量：</strong>{{ detailData.judgeCount }}个</div>
          <div><strong>题库描述：</strong>{{ detailData.remark }}</div>
        </el-card>

      </el-col>

      <el-col :span="24">

        <el-button :loading="loading" size="small" type="primary" icon="el-icon-caret-right" @click="handleCreate">
          开始练习
        </el-button>

        <el-button @click="handleBack" size="small">
          返回
        </el-button>

      </el-col>

    </el-row>
  </div>
</template>

<script>
import { createPaper } from '@/api/paper/exam'
import {fetchRepoDetail} from "../../../api/exam/exam";

export default {
  data() {
    return {
      detailData: {},
      postForm: {
        id: '',
      },
      loading: false
    }
  },

  created() {
    this.postForm.id = this.$route.params.examId
    this.fetchRepoDetail()
  },

  methods: {
    fetchRepoDetail() {
      fetchRepoDetail(this.postForm.id).then(response => {
        console.log("===========>"+response.data)
        this.detailData = response.data
      })
    },

    handleCreate() {
      // const that = this
      // this.loading = true
      //
      // createPaper(this.postForm).then(response => {
      //   console.log(response)
      //
      //   if (response.code === 0) {
      //     setTimeout(function() {
      //       this.loading = false
      //       that.dialogVisible = false
      //       that.$router.push({ name: 'StartTrain', params: { id: response.data.id }})
      //     }, 1000)
      //   }
      // }).catch(() => {
      //   this.loading = false
      // })



    },

    handleBack() {
      this.$router.push({ name: 'TrainOnline' })
    }

  }
}
</script>

<style scoped>

.pre-exam div {

  line-height: 42px;
  color: #555555;
}

</style>

